#include<bits/stdc++.h>
using namespace std;

int main(){ 
    int n,m;
    cin>>n>>m;
    int min = 100000;
    int arr[100001];
    int sum = 0;

    for(int i = 1;i<=n;i++){
        cin>>arr[i];
    }
    for(int i = 1;i<=n-m+1;i++){
        for(int j = 1;j<=m;j++){
            sum += arr[i+j-1];
        }
        if(sum < min){
            min = sum;
        } 
        sum = 0;
    }
    cout<<min<<endl;

    return 0;
}